/**
 * 获取树形的id
 * tree: 树形数据
 * arr: 获取id=[]
 * key 需要获取的key
 */
export const getTreeKey = (tree, arr, key = 'id') => {
  tree.map((x) => {
    arr.push(x[key])
    if (x && x.children) {
      getTreeKey(x.children, arr, key)
    }
    return x
  })
  return arr
}
/**
 * 格式化菜单列表
 * @param list
 * @returns
 */
export const formatMenuTreeData = (list: any) => {
  const data: any[] = []
  list.forEach((item: any) => {
    const netItem = {
      title: item.name,
      key: item.id,
      value: item.id,
    }
    if (item.hasOwnProperty('children')) {
      netItem['children'] = formatMenuTreeData(item['children'])
    }
    data.push(netItem)
  })
  return data
}
